﻿<UserControl x:Class="CAION2.Controls.StigmaPlace"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:controls="clr-namespace:CAION2.Controls"
             xmlns:viewModels="clr-namespace:CAION2.ViewModels"
             x:Name="Control"
             Width="80"
             Height="80"
             Background="Transparent"
             IsEnabled="{Binding IsEnabled}"
             ToolTipService.ShowDuration="36000">

    <UserControl.Resources>
        <ContextMenu x:Key="PlaceMenu" ItemsSource="{Binding ContextMenuItems}"/>
    </UserControl.Resources>

    <UserControl.DataContext>
        <viewModels:StigmaPlaceViewModel />
    </UserControl.DataContext>

    <UserControl.Style>
        <Style TargetType="{x:Type controls:StigmaPlace}">
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="BorderBrush" Value="{DynamicResource Accent}" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </UserControl.Style>
    
    <UserControl.ToolTip>
        <ToolTip>
            <controls:StigmaToolTip DataContext="{Binding ToolTipData, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"/>
        </ToolTip>
    </UserControl.ToolTip>

    <Canvas Width="{Binding Width, ElementName=Control}"
            Height="{Binding Height, ElementName=Control}"
            HorizontalAlignment="Stretch"
            VerticalAlignment="Stretch"
            ContextMenu="{StaticResource PlaceMenu}">

        <Image Width="{Binding Width, ElementName=Control}"
               Height="{Binding Height, ElementName=Control}"
               Source="{Binding Background,
                                Mode=OneWay,
                                UpdateSourceTrigger=PropertyChanged}"
               Stretch="Uniform" />

        <Image Width="39"
               Height="39"
               Margin="20,20,0,0"
               Panel.ZIndex="1"
               Source="{Binding Icon,
                                Mode=OneWay,
                                UpdateSourceTrigger=PropertyChanged}"
               Stretch="Uniform" />

        <Border Width="39"
                Height="39"
                Margin="21,20,0,0"
                Panel.ZIndex="4"
                Background="{Binding RedBackground,
                                     Mode=OneWay,
                                     UpdateSourceTrigger=PropertyChanged}"/>

        <Border Width="40"
                Height="41"
                Margin="20,19,0,0"
                Panel.ZIndex="7"
                BorderBrush="{Binding BorderBrush,
                                          ElementName=Control,
                                          Mode=OneWay}"
                BorderThickness="2" />

    </Canvas>


</UserControl>
